
** Import co-variates data (Narhoz Yearbooks)
set more off
import excel using "$data/narhoz_stats.xlsx", clear firstrow sheet("tovaroob_all") cellrange(B3:T85)
reshape long  trade, i(Birthplace) j(Year)
sort Birthplace Year
save "$datatemp/trade_oblast.dta", replace

import excel using "$data/narhoz_stats.xlsx", clear firstrow sheet("concrete_all") cellrange(B3:Q85)
reshape long concrete, i(Birthplace) j(Year)
sort Birthplace Year
save "$datatemp/concrete_oblast.dta", replace

import excel using "$data/narhoz_stats.xlsx", clear firstrow sheet("brick_all") cellrange(B3:Q85)
reshape long brick, i(Birthplace) j(Year)
sort Birthplace Year
save "$datatemp/brick_oblast.dta", replace

import excel using "$data/narhoz_stats.xlsx", clear firstrow sheet("meat_all") cellrange(B3:T85)
reshape long meat, i(Birthplace) j(Year)
sort Birthplace Year
save "$datatemp/meat_oblast.dta", replace

import excel using "$data/narhoz_stats.xlsx", clear firstrow sheet("timber_all") cellrange(B3:Q85)
reshape long timber, i(Birthplace) j(Year)
sort Birthplace Year
save "$datatemp/timber_oblast.dta", replace

import excel using "$data/narhoz_stats.xlsx", clear firstrow sheet("conserve_all") cellrange(B3:T85)
reshape long canned, i(Birthplace) j(Year)
sort Birthplace Year
save "$datatemp/canned_oblast.dta", replace


use "$datatemp/trade_oblast.dta", clear
foreach var of newlist concrete brick meat timber canned {
sort Birthplace Year
merge (Birthplace Year) using "$datatemp/`var'_oblast.dta"
tab _merge if Year==1980
tab Birthplace if _merge!=3 & Year==1980
drop _merge
}
sort Birthplace Year
save "$datatemp/covars_oblast.dta", replace

** Import wage data for 1980
import excel using "$data/narhoz_stats.xlsx", clear firstrow sheet("wage_80") cellrange(B3:C92)
sort Birthplace
save "$datatemp/wage_oblast80.dta", replace



